package com.oscarmovie.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.oscarmovie.model.Category;
import com.oscarmovie.model.Movie;

public class CategoryDaoImpl extends HibernateDaoSupport implements CategoryDao {

	public void save(Category movie) {
		getSession().saveOrUpdate(movie);
	}

	public Category load(int id) {
		Category category = (Category)getSession().load(Category.class, id);
		return category;
	}
	
	
	public List<Category> loadAll() {
		Query query = getSession().createQuery("from Category");
		query.setCacheable(true);
		List<Category> list = (List<Category>)query.list();
		return list;
	}
	
}
